package com.xxxx.seckill.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xxxx.seckill.pojo.Goods;
import com.xxxx.seckill.pojo.dto.GoodsDto;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author zhoubin
 * @since 2022-08-20
 */
public interface GoodsMapper extends BaseMapper<Goods> {

    @Select("SELECT\n" +
            "\tg.*,\n" +
            "\tsg.seckill_price,\n" +
            "\tsg.stock_count,\n" +
            "\tsg.end_date,\n" +
            "\tsg.start_date \n" +
            "FROM\n" +
            "\tt_goods g\n" +
            "\tLEFT JOIN t_seckill_goods sg ON g.id = sg.goods_id;")
    public List<GoodsDto> getGoodsAll();

    @Select("SELECT\n" +
            "\tg.*,\n" +
            "\tsg.seckill_price,\n" +
            "\tsg.stock_count,\n" +
            "\tsg.end_date,\n" +
            "\tsg.start_date \n" +
            "FROM\n" +
            "\tt_goods g\n" +
            "\tLEFT JOIN t_seckill_goods sg ON g.id = sg.goods_id  where sg.goods_id = #{id};")
    public GoodsDto getDetail(int id);

}
